package net.zdsoft.wpchat.support.action.frame;

import javax.annotation.Resource;

import net.zdsoft.keel.util.Validators;
import net.zdsoft.wpchat.android.client.BasicAction;
import net.zdsoft.wpchat.support.service.AuthService;
import net.zdsoft.wpchat.support.service.OperatorService;

/**
 * 后台支持登录Action（主要用来修改密码）
 * 
 * @author xuan
 * @version $Revision: 1.0 $, $Date: 2014-9-22 下午8:30:13 $
 */
public class SupportLoginAction extends BasicAction {
    private static final long serialVersionUID = 8193170512364820279L;

    @Resource
    private OperatorService operatorService;
    @Resource
    private AuthService authService;

    private String username;
    private String password;
    private String newPassword;
    private String verifyPassword;
    private String verifyCode;
    private String rePassword;

    /**
     * 显示修改密码页面
     * 
     * @return
     */
    public String preChangePassword() {
        return SUCCESS;
    }

    /**
     * 修改密码
     * 
     * @return
     */
    public String changePass() {
        if (Validators.isEmpty(password)) {
            addActionError("密码不能为空");
            return INPUT;
        }

        if (!newPassword.equals(verifyPassword)) {
            addActionError("两次输入的密码不一致");
            return INPUT;
        }

        authService.modifyPassword(getSupportMemoryUser().getId(), password);
        addActionMessage("密码修改成功！");
        return SUCCESS;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String userName) {
        username = userName;
    }

    public String getNewPassword() {
        return newPassword;
    }

    public void setNewPassword(String newPassword) {
        this.newPassword = newPassword;
    }

    public String getVerifyPassword() {
        return verifyPassword;
    }

    public void setVerifyPassword(String verifyPassword) {
        this.verifyPassword = verifyPassword;
    }

    public String getVerifyCode() {
        return verifyCode;
    }

    public void setVerifyCode(String verifyCode) {
        this.verifyCode = verifyCode;
    }

    public String getRePassword() {
        return rePassword;
    }

    public void setRePassword(String rePassword) {
        this.rePassword = rePassword;
    }

}
